下方使用到 var
是早期 Google App Script 只支援 ES5 的規範,之後開始支援 ES6 規範,但不完整導致 let
無法在 Google App Script 使用,這此等進行到 LINT 時再一起調整 😊
function (sheetData) {
return sheetData
.reduce(function(results, data) {
var [status, title, flag, startDate, endDate,
location, oversea, link,
ticketSource, ticketStartTime, ticketEndTime,
c4sSource, c4sStartTime, c4sEndTime,
] = data;
results.push([status, title, flag, startDate, endDate,
location, oversea, link,
ticketSource, ticketStartTime, ticketEndTime,
c4sSource, c4sStartTime, c4sEndTime,
]);
return results;
}, [])
.filter(function(data) {
var thisYear = (new Date()).getFullYear();
var [status, title, flag, startDate, endDate,
location, oversea, link,
ticketSource, ticketStartTime, ticketEndTime,
c4sSource, c4sStartTime, c4sEndTime,
] = data;
if (status !== 'success') {
return false;
}
return new Date(endDate).getFullYear() >= thisYear;
})
.sort(function(currentValue, nextValue) {
return (new Date(currentValue[3]).getTime() - new Date(nextValue[3]).getTime());
});
}